.class public Lcom/opongo/blogapp/C2DMReceiver;
.super Lcom/google/android/c2dm/C2DMBaseReceiver;
.source "C2DMReceiver.java"


# static fields
#the value of this static final field might be set in the static constructor
.field public static final DEBUG:Z = false

.field private static final HELLO_ID:I = 0x1

.field public static final PREFS_NAME:Ljava/lang/String; = "BlogApp"

.field private static final TAG:Ljava/lang/String;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 34
    sget-boolean v0, Lcom/opongo/blogapp/AbaSettings;->DEBUG:Z

    sput-boolean v0, Lcom/opongo/blogapp/C2DMReceiver;->DEBUG:Z

    .line 35
    const-class v0, Lcom/opongo/blogapp/C2DMReceiver;

    invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/opongo/blogapp/C2DMReceiver;->TAG:Ljava/lang/String;

    .line 32
    return-void
.end method

.method public constructor <init>()V
    .locals 1

    .prologue
    .line 40
    const-string v0, "app.opongo@gmail.com"

    invoke-direct {p0, v0}, Lcom/google/android/c2dm/C2DMBaseReceiver;-><init>(Ljava/lang/String;)V

    .line 41
    return-void
.end method

.method static synthetic access$0()Ljava/lang/String;
    .locals 1

    .prologue
    .line 35
    sget-object v0, Lcom/opongo/blogapp/C2DMReceiver;->TAG:Ljava/lang/String;

    return-object v0
.end method


# virtual methods
.method public onError(Landroid/content/Context;Ljava/lang/String;)V
    .locals 1
    .parameter "context"
    .parameter "errorId"

    .prologue
    .line 83
    sget-boolean v0, Lcom/opongo/blogapp/C2DMReceiver;->DEBUG:Z

    if-eqz v0, :cond_0

    .line 84
    const-string v0, "C2DMReceiver-onError"

    invoke-static {v0, p2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 85
    :cond_0
    return-void
.end method

.method protected onMessage(Landroid/content/Context;Landroid/content/Intent;)V
    .locals 22
    .parameter "context"
    .parameter "intent"

    .prologue
    .line 89
    sget-boolean v19, Lcom/opongo/blogapp/C2DMReceiver;->DEBUG:Z

    if-eqz v19, :cond_0

    .line 90
    const-string v19, "C2DMReceiver"

    const-string v20, "payload"

    move-object/from16 v0, p2

    move-object/from16 v1, v20

    invoke-virtual {v0, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v20

    invoke-static/range {v19 .. v20}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 91
    const-string v19, "C2DMReceiver"

    new-instance v20, Ljava/lang/StringBuilder;

    const-string v21, "Sound: "

    invoke-direct/range {v20 .. v21}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v21, "sound"

    move-object/from16 v0, p2

    move-object/from16 v1, v21

    invoke-virtual {v0, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v21

    invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v20

    invoke-virtual/range {v20 .. v20}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v20

    invoke-static/range {v19 .. v20}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 92
    const-string v19, "C2DMReceiver"

    new-instance v20, Ljava/lang/StringBuilder;

    const-string v21, "Post ID: "

    invoke-direct/range {v20 .. v21}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v21, "post_id"

    move-object/from16 v0, p2

    move-object/from16 v1, v21

    invoke-virtual {v0, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v21

    invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v20

    invoke-virtual/range {v20 .. v20}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v20

    invoke-static/range {v19 .. v20}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 95
    :cond_0
    const-string v11, "notification"

    .line 96
    .local v11, ns:Ljava/lang/String;
    move-object/from16 v0, p0

    invoke-virtual {v0, v11}, Lcom/opongo/blogapp/C2DMReceiver;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v8

    check-cast v8, Landroid/app/NotificationManager;

    .line 98
    .local v8, mNotificationManager:Landroid/app/NotificationManager;
    const v7, 0x7f020017

    .line 99
    .local v7, icon:I
    const-string v19, "payload"

    move-object/from16 v0, p2

    move-object/from16 v1, v19

    invoke-virtual {v0, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v15

    .line 100
    .local v15, tickerText:Ljava/lang/CharSequence;
    const-string v19, "sound"

    move-object/from16 v0, p2

    move-object/from16 v1, v19

    invoke-virtual {v0, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v14

    .line 101
    .local v14, sound:Ljava/lang/String;
    const-string v19, "post_id"

    move-object/from16 v0, p2

    move-object/from16 v1, v19

    invoke-virtual {v0, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v19

    invoke-static/range {v19 .. v19}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

    move-result-object v19

    invoke-virtual/range {v19 .. v19}, Ljava/lang/Integer;->intValue()I

    move-result v12

    .line 102
    .local v12, post_id:I
    const-string v19, "badge"

    move-object/from16 v0, p2

    move-object/from16 v1, v19

    invoke-virtual {v0, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v19

    invoke-static/range {v19 .. v19}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

    move-result-object v19

    invoke-virtual/range {v19 .. v19}, Ljava/lang/Integer;->intValue()I

    move-result v3

    .line 104
    .local v3, badge:I
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v17

    .line 106
    .local v17, when:J
    new-instance v9, Landroid/app/Notification;

    move-wide/from16 v0, v17

    invoke-direct {v9, v7, v15, v0, v1}, Landroid/app/Notification;-><init>(ILjava/lang/CharSequence;J)V

    .line 108
    .local v9, notification:Landroid/app/Notification;
    const-string v19, "default"

    move-object/from16 v0, v19

    invoke-virtual {v14, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v19

    if-eqz v19, :cond_5

    .line 109
    sget-boolean v19, Lcom/opongo/blogapp/C2DMReceiver;->DEBUG:Z

    if-eqz v19, :cond_1

    .line 110
    sget-object v19, Lcom/opongo/blogapp/C2DMReceiver;->TAG:Ljava/lang/String;

    const-string v20, "play default sound"

    invoke-static/range {v19 .. v20}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 111
    :cond_1
    iget v0, v9, Landroid/app/Notification;->defaults:I

    move/from16 v19, v0

    or-int/lit8 v19, v19, 0x1

    move/from16 v0, v19

    iput v0, v9, Landroid/app/Notification;->defaults:I

    .line 119
    :cond_2
    :goto_0
    invoke-virtual/range {p0 .. p0}, Lcom/opongo/blogapp/C2DMReceiver;->getBaseContext()Landroid/content/Context;

    move-result-object v19

    invoke-static/range {v19 .. v19}, Landroid/preference/PreferenceManager;->getDefaultSharedPreferences(Landroid/content/Context;)Landroid/content/SharedPreferences;

    move-result-object v13

    .line 121
    .local v13, prefs:Landroid/content/SharedPreferences;
    const-string v19, "toggleButtonPushVibrate"

    const/16 v20, 0x0

    move-object/from16 v0, v19

    move/from16 v1, v20

    invoke-interface {v13, v0, v1}, Landroid/content/SharedPreferences;->getBoolean(Ljava/lang/String;Z)Z

    move-result v19

    invoke-static/range {v19 .. v19}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v16

    .line 123
    .local v16, vibrate:Ljava/lang/Boolean;
    invoke-virtual/range {v16 .. v16}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v19

    if-eqz v19, :cond_3

    .line 124
    iget v0, v9, Landroid/app/Notification;->defaults:I

    move/from16 v19, v0

    or-int/lit8 v19, v19, 0x2

    move/from16 v0, v19

    iput v0, v9, Landroid/app/Notification;->defaults:I

    .line 126
    :cond_3
    iget v0, v9, Landroid/app/Notification;->defaults:I

    move/from16 v19, v0

    or-int/lit8 v19, v19, 0x4

    move/from16 v0, v19

    iput v0, v9, Landroid/app/Notification;->defaults:I

    .line 128
    iget v0, v9, Landroid/app/Notification;->flags:I

    move/from16 v19, v0

    or-int/lit8 v19, v19, 0x10

    move/from16 v0, v19

    iput v0, v9, Landroid/app/Notification;->flags:I

    .line 130
    const/16 v19, 0x1

    move/from16 v0, v19

    if-le v3, v0, :cond_4

    .line 131
    iput v3, v9, Landroid/app/Notification;->number:I

    .line 133
    :cond_4
    const/high16 v19, 0x7f07

    move-object/from16 v0, p1

    move/from16 v1, v19

    invoke-virtual {v0, v1}, Landroid/content/Context;->getString(I)Ljava/lang/String;

    move-result-object v6

    .line 134
    .local v6, contentTitle:Ljava/lang/CharSequence;
    const-string v19, "payload"

    move-object/from16 v0, p2

    move-object/from16 v1, v19

    invoke-virtual {v0, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    .line 136
    .local v5, contentText:Ljava/lang/CharSequence;
    new-instance v10, Landroid/content/Intent;

    const-class v19, Lcom/opongo/blogapp/activities/PostsActivity;

    move-object/from16 v0, p0

    move-object/from16 v1, v19

    invoke-direct {v10, v0, v1}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    .line 137
    .local v10, notificationIntent:Landroid/content/Intent;
    const-string v19, "POST_ID"

    move-object/from16 v0, v19

    invoke-virtual {v10, v0, v12}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    .line 138
    const/high16 v19, 0x1400

    move/from16 v0, v19

    invoke-virtual {v10, v0}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;

    .line 139
    const/16 v19, 0x0

    .line 140
    const/high16 v20, 0x800

    .line 139
    move-object/from16 v0, p0

    move/from16 v1, v19

    move/from16 v2, v20

    invoke-static {v0, v1, v10, v2}, Landroid/app/PendingIntent;->getActivity(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v4

    .line 142
    .local v4, contentIntent:Landroid/app/PendingIntent;
    move-object/from16 v0, p1

    invoke-virtual {v9, v0, v6, v5, v4}, Landroid/app/Notification;->setLatestEventInfo(Landroid/content/Context;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Landroid/app/PendingIntent;)V

    .line 145
    const/16 v19, 0x1

    move/from16 v0, v19

    invoke-virtual {v8, v0, v9}, Landroid/app/NotificationManager;->notify(ILandroid/app/Notification;)V

    .line 146
    return-void

    .line 112
    .end local v4           #contentIntent:Landroid/app/PendingIntent;
    .end local v5           #contentText:Ljava/lang/CharSequence;
    .end local v6           #contentTitle:Ljava/lang/CharSequence;
    .end local v10           #notificationIntent:Landroid/content/Intent;
    .end local v13           #prefs:Landroid/content/SharedPreferences;
    .end local v16           #vibrate:Ljava/lang/Boolean;
    :cond_5
    const-string v19, ""

    move-object/from16 v0, v19

    invoke-virtual {v14, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v19

    if-nez v19, :cond_2

    .line 113
    sget-boolean v19, Lcom/opongo/blogapp/C2DMReceiver;->DEBUG:Z

    if-eqz v19, :cond_6

    .line 114
    sget-object v19, Lcom/opongo/blogapp/C2DMReceiver;->TAG:Ljava/lang/String;

    const-string v20, "play custom sound"

    invoke-static/range {v19 .. v20}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 115
    :cond_6
    invoke-static {v14}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v19

    move-object/from16 v0, v19

    iput-object v0, v9, Landroid/app/Notification;->sound:Landroid/net/Uri;

    goto/16 :goto_0
.end method

.method public onRegistered(Landroid/content/Context;Ljava/lang/String;)V
    .locals 3
    .parameter "context"
    .parameter "registrationId"

    .prologue
    .line 45
    const-string v1, "C2DMReceiver-onRegistered"

    invoke-static {v1, p2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 47
    new-instance v0, Lcom/opongo/blogapp/manager/APIManager;

    invoke-direct {v0, p0}, Lcom/opongo/blogapp/manager/APIManager;-><init>(Landroid/content/Context;)V

    .line 54
    .local v0, apiManager:Lcom/opongo/blogapp/manager/APIManager;
    new-instance v1, Ljava/lang/Thread;

    new-instance v2, Lcom/opongo/blogapp/C2DMReceiver$1;

    invoke-direct {v2, p0, v0, p2}, Lcom/opongo/blogapp/C2DMReceiver$1;-><init>(Lcom/opongo/blogapp/C2DMReceiver;Lcom/opongo/blogapp/manager/APIManager;Ljava/lang/String;)V

    invoke-direct {v1, v2}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    .line 72
    invoke-virtual {v1}, Ljava/lang/Thread;->start()V

    .line 73
    return-void
.end method

.method public onUnregistered(Landroid/content/Context;)V
    .locals 2
    .parameter "context"

    .prologue
    .line 77
    sget-boolean v0, Lcom/opongo/blogapp/C2DMReceiver;->DEBUG:Z

    if-eqz v0, :cond_0

    .line 78
    const-string v0, "C2DMReceiver-onUnregistered"

    const-string v1, "got here!"

    invoke-static {v0, v1}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 79
    :cond_0
    return-void
.end method
